<?php
class Msetting extends CI_Model{
	protected $_table="tpt_setting";
	public function __construct(){
		parent::__construct();	
		$this->load->database();
	} 	
	
	public function count_row(){
         return $this->db->count_all($this->_table);
    }
	
	public function insert($data){
		$this->db->insert($this->_table,$data);
	}
	
	public function update($data){
		$this->db->update($this->_table,$data);
	}
	
	public function get_data(){
		$this->db->select();
		$this->db->from($this->_table);
		return $this->db->get()->row_array();	
	}
	
	public function get($col) {
        $row = $this->count_row_col($col);
		if($row == 0){
			return $col;	
		}else{
			$this->db->select($col);
			$this->db->from($this->_table);
			return $this->db->get()->row_array();	
		}        
    }
	
	public function count_row_col($col){
		$this->db->select($col);
		return $this->db->get($this->_table)->num_rows();
	}
}